package entity;

import java.util.Date;

public class Message {
    private int messageId;         // 消息ID
    private int senderId;          // 发送者用户ID
    private int receiverId;        // 接收者用户ID
    private String content;        // 消息内容
    private Date sendTime;         // 发送时间
    private boolean isRead;        // 是否已读

    // 构造方法（用于创建新消息）
    public Message(int senderId, int receiverId, String content) {
        this.senderId = senderId;
        this.receiverId = receiverId;
        this.content = content;
        this.sendTime = new Date();  // 默认当前时间
        this.isRead = false;         // 初始未读
    }

    // Getter和Setter方法
    public int getMessageId() { return messageId; }
    public void setMessageId(int messageId) { this.messageId = messageId; }
    public int getSenderId() { return senderId; }
    public int getReceiverId() { return receiverId; }
    public String getContent() { return content; }
    public Date getSendTime() { return sendTime; }
    public boolean isRead() { return isRead; }
    public void setRead(boolean read) { isRead = read; }
}

/*
* CREATE TABLE messages (
    message_id INT PRIMARY KEY AUTO_INCREMENT,
    sender_id INT NOT NULL,  -- 发送者ID（关联users表）
    receiver_id INT NOT NULL,  -- 接收者ID（关联users表）
    content TEXT NOT NULL,  -- 消息内容
    send_time DATETIME DEFAULT CURRENT_TIMESTAMP,  -- 发送时间
    is_read BOOLEAN DEFAULT FALSE,  -- 是否已读
    FOREIGN KEY (sender_id) REFERENCES users(user_id),
    FOREIGN KEY (receiver_id) REFERENCES users(user_id)
);*/